package org.xxmi.ch3;

import org.junit.Test;

public class Test3 {

    @Test
    public void test1() {
        boolean part = Character.isJavaIdentifierPart('~');
        System.out.println(part);
    }

    @Test
    public void test2() {
        double x = 4;
        double y = Math.sqrt(x);
        System.out.println(y);
        System.out.println(Math.pow(x, 3));
        int abs = StrictMath.abs(10);
        System.out.println("abs: " + abs);
        double abs1 = StrictMath.abs(12.123);
        System.out.println(abs1);
    }

    @Test
    public void test3() {
        int n = 123456789;
        float f = n;
        System.out.println(f);
        float a = n + f;
        System.out.println(a);
        int b = (int) 9.991;
        System.out.println(b);
        System.out.println(Math.round(3.145));
        System.out.println(Math.round(3.5));
        long round = Math.round(3.14515246546); //
        int round1 = Math.round(3.14F); // 浮点数
        double v = 3.15;    // 默认情况下浮点数是一个double 类型的，除非显示的在末尾添加 F 符号，這时则是 float 类型的
        float v1 = 3.15F;
    }

    @Test
    public void test4() {
        int x = 5;
        System.out.println(x += 1); // x = x+1
        System.out.println(x -= 1); // x = x-1
        System.out.println(x *= 2); // x = x*2
        System.out.println(x /= 2); // x = x/2
        int y = x += 3.5;
        System.out.println(y);
    }

    @Test
    public void test5() {
        int n = 10;
        int m = 10;
        int a = 2 * ++n;
        int b = 2 * m++;
        System.out.println(a);
        System.out.println(b);
        int y = 10;
        System.out.println(y++);
    }

    @Test
    public void test6() {
        int b = 1;
        int c = 1;
        int a = 2;
        a += b += c;
        // b = b + c;
        // a = a + b;
        System.out.println(a);
    }

    @Test
    public void test7() {
        MySize s = MySize.SMALL;
        String info = "123456789";
        String substring = info.substring(3);
        System.out.println(substring);
        String substring1 = info.substring(0, 3);
        System.out.println(substring1);
        String all = String.join("/", "S", "M", "L", "XL");
        System.out.println(all);
    }

    @Test
    public void test8(){
        String info = "hello";
        System.out.println(info == "hello"); // true
        System.out.println(info.substring(0,2) == "he");
    }


}
